// 插入子表的行

import insertSubTableRow from '../../request-functions/insertSubTableRow';
import deepCopy from '../../../../public/functions/deep-copy';

export default async function(tableId, index) {

    const {
        cardTable: {
            addRow
        },
        form: {
            getAllFormValue
        }
    } = this.props;

    const {
        humanResourceOrganizationValue: {
            refpk
        }
    } = this.state;

    let postData = {
        func_type: '2',
        pk_org: refpk,
        psnjobForm: deepCopy(getAllFormValue('hi_psnjob_h')),
        table_code: tableId
    };

    try {
        let res = await insertSubTableRow(postData);

        addRow(tableId, index, deepCopy(res.data[tableId].rows[0].values), false);
    }
    catch(e) {
    }

}
